package cc.eddic.practice.spring.dto;

import cc.eddic.practice.spring.domain.SubCategory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SubCategoryResponse {
    private  Long id;
    private String name;
    private Long categoryId;

    public static SubCategoryResponse from(final SubCategory subCategory){
        val dto=new SubCategoryResponse();
        BeanUtils.copyProperties(subCategory,dto);
        dto.categoryId=subCategory.getCategory().getId();
        return dto;
    }
}
